<!--#include file="../../core/common/Conn.asp" -->
<!--#include file="../../core/common/MD5.asp" -->
<!--#include file="../../core/common/Limit.asp" -->
<%
	dim action
	action = request.QueryString("action")
	if action = "edit" then
		call edit
	else
		call default
	end if
	
	dim ID,USERNAME,PASSWORD,NAME
	
	'加载默认资料
	sub default
		ID = request.QueryString("id")
		
		dim rs,sql
		sql = "select * from [USERS] where ID = " & ID
		set rs = db.query(sql)
		if not rs.eof then
			ID = rs("ID")
			USERNAME = rs("USERNAME")
			NAME = rs("NAME")
		end if
		rs.close
		set rs = nothing
	end sub
	
	'修改个人资料
	sub edit
		ID = request.Form("ID")
		USERNAME = request.Form("USERNAME")
		PASSWORD = request.Form("PASSWORD")
		NAME = request.Form("NAME")
	
		dim rs,sql
		sql = "select * from [USERS] where ID = "& ID
		set rs = db.query(sql)
		if not rs.eof then
			if PASSWORD <> "" then
				rs("PASSWORD") = MD5(PASSWORD)
			end if
			rs("USERNAME") = USERNAME
			rs("NAME") = NAME
			rs.update
		end if
		rs.close
		set rs = nothing
		
		response.Redirect("list.asp")
	end sub
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CMSLite for ASP</title>
<link href="../resource/css/reset.css" rel="stylesheet" type="text/css" />
<link href="../resource/css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../resource/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="../resource/js/common.js"></script>
</head>

<body id="body">
	<div class="title_bar">
	修改用户资料
	</div>
	<form action="?action=edit" method="post">
	<p>
		<label>用户名</label>
		<input type="text" class="textbox" name="USERNAME" value="<%=USERNAME%>" />
	</p>
	<p>
		<label>密码</label>
		<input type="text" class="textbox" name="PASSWORD" />
	</p>
	<p>
		<label>姓名</label>
		<input type="text" class="textbox" name="NAME" value="<%=NAME%>" />
	</p>
	<p>
		<input type="submit" class="button_1" value="修改" />
		<input type="button" class="button_1" value="取消" onclick="location.href='list.asp';" />
		<input type="hidden" name="ID" value="<%=ID%>" />
	</p>
	</form>
</body>
</html>
